<!DOCTYPE html>
<html>
<head>
<title>CRM</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- 
<link rel="stylesheet" type="text/css" href="lib/extjs/resources/css/ext-all.css">
<link rel="stylesheet" type="text/css" href="lib/extjs/resources/css/ext-all-gray.css">
 -->
<link rel="stylesheet" type="text/css" href="extlib/extjs/resources/css/ext-all-access.css">
<!-- 
<script type="text/javascript" src="lib/extjs/bootstrap.js?t=nodebug"></script>
<script type="text/javascript" src="lib/extjs/ext-all-debug-w-comments.js"></script>
 -->
<script type="text/javascript" src="extlib/extjs/ext-all.js"></script>
<script type="text/javascript" src="extlib/extjs/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="js/common.js"></script>
</head>
<body>
<span style="cursor: pointer;"></span>
<script type="text/javascript">

var wWidth = 480;
var wHeight = 180;

Ext.onReady(function() {

    // do login
    var dologin = function(form) {
    	form.submit({
            success: function(form, action) {
            	if (action.result.success == "true") {
            		top.location = action.result.forward;
            	} else {
            		Ext.Msg.alert("提示信息", action.result.errorMsgs);
            	}
            },
            failure: function(form, action) {
                Ext.Msg.alert("提示信息", action.result.errorMsgs);
            }
        });
    };

    var loginWin = Ext.create("Ext.window.Window", {
        title: "系统登录",
        width: wWidth,
        height: wHeight,
        layout: "border",
        closable: false,
        resizable: false,
        border: 0,
        modal: true,
        items: [{
        	region: "center",
            xtype: "form",
            url: "auth/login.shtm",
            frame:true,
            buttonAlign: "center",
            bodyStyle: "padding:20px 50px",
            width: wWidth,
            fieldDefaults: {
                width: 280,
                labelWidth: 90,
                height: 32,
                labelStyle: "padding-left:15px",
                fieldStyle: "font-size: 16px; font-weight: bold;",
            },
            defaultType: "textfield",
            items: [{
                id: "uid",
                fieldLabel: "用户ID",
                name: "uid",
                allowBlank: false
            },{
                fieldLabel: "密码",
                name: "password",
                inputType: "password",
                allowBlank: false,
                enableKeyEvents: true,
                listeners: {
                    keyup: {
                        fn: function(text, evt, opts) {
                            if (evt.getKey() == Ext.EventObject.ENTER) {
                                dologin(this.up("form").getForm());
                            }
                        }
                    }
                }
            }],

            buttons: [{
                text: "重置",
                handler: function() {
                    this.up("form").getForm().reset();
                    Ext.getCmp("uid").focus();
                }
            },{
                text: "登录",
                id: "btn_login",
                handler: function() {
                    dologin(this.up("form").getForm());
                }
            }]
        }]
    });

    // show window
    loginWin.show(document.body, function() {
        var p = loginWin.getPosition();
        loginWin.setPosition(p[0], p[1] * .7);
        setTimeout(function() {
            Ext.getCmp("uid").focus();
        }, 100);
    });
});

</script>
</body>
</html>
